package com.dzt.androidframework.activity;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;

import com.dzt.androidframework.R;
import com.dzt.androidframework.utils.JToastKit;

import org.xutils.view.annotation.Event;
import org.xutils.view.annotation.ViewInject;



public class ActivityRegister extends ActivityTitle {

	@ViewInject(R.id.et_account)
	private EditText etAccount;
	@ViewInject(R.id.et_pwd)
	private EditText etPwd;
	@ViewInject(R.id.et_re_pwd)
	private EditText etRePwd;

	@Override
	protected int getLayoutId() {
		return R.layout.activity_register;
	}

	@Override
	protected void initParams() {
		setTitleView(R.string.title_register);
	}

	@Override
	protected void initData(Bundle savedInstanceState) {

	}

	@Override
	protected String[] initPermissions() {
		return null;
	}

	@Event(value = {R.id.btn_register})
	private void onViewClick(View v) {
		switch (v.getId()) {
			case R.id.btn_register:
				register();
				break;
			default:
				break;
		}
	}

	private void register(){
		String account = etAccount.getText().toString().trim();
		String pwd = etPwd.getText().toString().trim();
		String rePwd = etRePwd.getText().toString().trim();
		if(TextUtils.isEmpty(account)
				|| TextUtils.isEmpty(pwd)
				|| TextUtils.isEmpty(rePwd)){
			JToastKit.getInstance().showMessage("用户名或密码不能为空");
			return;
		}

		if(!pwd.equals(rePwd)){
			JToastKit.getInstance().showMessage("两次输入的密码不一致");
			return;
		}

//		BmobUser ub = new BmobUser();
//		ub.setUsername(account);
//		ub.setPassword(pwd);
//		ub.signUp(new SaveListener<BmobUser>() {
//			@Override
//			public void done(BmobUser userBean, BmobException e) {
//				if(e == null){
//					ToastUtil.getInstance(context).showMessage("注册成功");
//				}else{
//					ToastUtil.getInstance(context).showMessage("注册失败");
//				}
//			}
//		});
	}
}
